﻿/* 2. Write a program that prints all the numbers from 1 to N, 
 * that are not divisible by 3 and 7 at the same time. */

using System;

public class FirstNWithoutSomeSpecial
{
    public static void Main()
    {
        int divisor = 3 * 7;
        int firstNumber = 1;
        int lastNumber;
        int allMembers;
        sbyte sign = 1;
        int i = 0;
        int temporary;

        do
        {
            Console.Clear();
            Console.Write("Divisor = ");
            if ((int.TryParse(Console.ReadLine(), out divisor)) && (divisor != 0))
                break;
        } while (true);

        do
        {
            Console.Clear();
            Console.Write("Divisor = {0}\nFirst number = ", divisor);
            if (int.TryParse(Console.ReadLine(), out firstNumber))
                break;
        } while (true);

        do
        {
            Console.Clear();
            Console.Write("Divisor = {0}\nFirst number = {1}\nLast number = ", divisor, firstNumber);
            if (int.TryParse(Console.ReadLine(), out lastNumber))
                break;
        } while (true);

        if (lastNumber < firstNumber)
        {
            allMembers = firstNumber - lastNumber + 1;
            sign = -1;
        }
        else
            allMembers = lastNumber - firstNumber + 1;

        for (; i < allMembers; i++)
        {
            temporary = firstNumber + i * sign;
            if (temporary % divisor != 0)
            {
                Console.Write(temporary);
                i++;
                break;
            }
        }
        
        for (; i < allMembers; i++)
        {
            temporary = firstNumber + i * sign;
            if (temporary % divisor != 0)
                Console.Write(", {0}", temporary);
        }

        Console.WriteLine();
    }
}